%% @author Hee Yeon Cho <aposto@nexon.co.kr>
%% @copyright 2009 Nexon Corporation.

%% @doc 
%%      
	
-module(savage_tcp_handler).
-author('aposto@nexon.co.kr').

% protobuffs_compile:scan_file

%% API
-export([handle/1]).

-define(NOTEST, true).
-include_lib("eunit/include/eunit.hrl").

%  c(d_matchman, [debug_info, {d,'TEST'}]). 
%  eunit:test(d_matchman, [verbose]).

%% handlers
handle(Bin) when size(Bin) < 4 ->
	io:format("handle: invalid bin ~n");
handle(<< 1:16, Rest/binary >>) ->	
	io:format("handle: login ~p~n", [Rest]);
handle(Bin) ->
	io:format("handle: unknown ~p~n", [Bin]),
	throw(undefined_proto).

	
%% Internal functions

%% Test suites
handle_test() ->
	[	%?assertException( throw, undefined_proto , handle(<<"korea">>) )
		?assertThrow( undefined_proto , handle(<<"korea">>) )
	].
		
handle_login_test() ->
	[	
		?assert(  ok == handle(<< 1:16, 2:16, "data" >>) )
	].